fix: implement missing utilities and fix edge-case bugs#235
Open
stooit wants to merge 1 commit into
Open
Conversation
Make all 60 tests pass across 5 source modules: - calculator: divide now throws on division by zero - string-utils: fix wordCount for consecutive spaces; implement truncate - task-manager: complete missing remove/update/sortBy methods - date-utils: use Math.round for day boundary (36h -> 2 days ago) - validator: isEmail allows long TLDs/subdomains; isUrl accepts ports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 16 previously-failing tests across 5 utility modules. All 60 tests now pass (
bun test), andtsc --noEmitis clean. No test files were modified and no dependencies were added — fixes are minimal and scoped to what the tests require.Changes
src/calculator.ts—dividenow throws"Division by zero"when the divisor is0(was returningInfinity).src/string-utils.ts—wordCounttrims and splits on/\s+/so consecutive spaces no longer count as words;truncateimplemented (returns unchanged within limit, truncates at word boundary, ellipsis counts towardmaxLength, handles strings shorter than the ellipsis).src/task-manager.ts— completed the missing/incompleteremove,update, andsortBymethods (priority high→medium→low;createdAtoldest-first; unknown IDs returnfalse).src/date-utils.ts—formatRelativeusesMath.roundinstead ofMath.floorfor the day count, fixing the off-by-one (36 hours → "2 days ago").src/validator.ts—isEmailaccepts long TLDs and subdomains (e.g.user@example.museum);isUrlaccepts URLs with a port (e.g.http://localhost:3000).Verification
bun test: 60 pass / 0 failbunx tsc --noEmit: cleanNotes / Assumptions
truncatewithmaxLength <= 0, the 23h59m cosmetic boundary informatRelative, and alphabetical ordering forsortBy("status"). None are exercised by the suite and none are regressions.